/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-04-14 21:08:58
 * @LastEditTime: 2024-07-07 13:05:45
 * @FilePath: /nest_study/web/src/views/system/dict/data/columns.tsx
 */
import { Button, Flex } from "antd";
import { formateLocalDateTime } from "@/utils";
import ShowDictionary from "@/components/dictionary_label";
import { statusList } from "../dictionary";

export const columns = (edit: Function, remove: Function) => [
    {
        title: '字典类型',
        dataIndex: 'parent',
        ellipsis: true
    },
    {
        title: '字典标签',
        dataIndex: 'label',
        ellipsis: true
    },
    {
        title: '字典键值',
        dataIndex: 'value',
        ellipsis: true
    },
    {
        title: '状态',
        dataIndex: 'status',
        ellipsis: true,
        render: (text: any, _row: any, _index: number) => <ShowDictionary list={statusList} label={'label'} value={text} />,
    },
    {
        title: '备注',
        dataIndex: 'remark',
    },
    {
        title: '更新时间',
        dataIndex: 'updateTime',
        width: 165,
        render: (text: any, _row: any, _index: number) => <p>{formateLocalDateTime(text)}</p>,
    },
    {
        title: '操作',
        dataIndex: 'action',
        width: 120,
        align: "center" as "center",
        fixed: 'right' as 'right',
        render: (_text: any, _row: any, _index: number) => <Flex gap={10} align="center">
            <Button size="small" onClick={() => edit(_row)}>编辑</Button>
            <Button size="small" type="primary" onClick={() => remove(_row)} danger>删除</Button>
        </Flex>,
    }
]